﻿using System.Web;
using Summer.Object;
using Summer.Log;

#region License
/*
 *  Copyright (c) Dumuzi.cn 2009 , All rights reserved.
 *  CLR Version: 2.0.50727.4927
 *  NameSpace: Summer.Web.Support
 *  Author:Edwin Tai,戴佳顺
 *  Msn:edwin19861218@hotmail.com
 *  QQ: 1961218
 *  Date:2009/11/2 13:05:23
 *  Licensed under the Microsoft Public License (Ms-PL)
 *  This license governs use of the accompanying software. 
 *  If you use the software, you accept this license.
 *  If you do not accept the license, do not use the software.
 */
#endregion

namespace Summer.Web.Support
{
    /// <summary>
    /// Abstract httpapplication class
    /// Override its ApplicationStart and ApplicationEnd methods
    /// </summary>
    /// <typeparam name="T">HttpApplication object to get HttpApplicationState</typeparam>
    public abstract class AbstractExtensibleHttpApplication<T> : HttpApplication, IExtensionObject<T>
        where T:HttpApplication
    {
        protected ILog logger = LogFactory.GetLogger(typeof(T));
        /// <summary>
        /// The application start methods to override
        /// </summary>
        /// <param name="additional"></param>
        /// <returns></returns>
        protected virtual bool ApplicationStart(T additional)
        {
            return true;
        }
        /// <summary>
        /// The application end  methods to override
        /// </summary>
        /// <returns></returns>
        protected virtual bool ApplicationEnd()
        {
            return true;
        }

        #region IExtensionObject<T> 成员

        bool IExtensionObject<T>.Load(T additional)
        {
            return this.ApplicationStart(additional);
        }

        bool IExtensionObject<T>.UnLoad()
        {
            return this.ApplicationEnd();
        }

        #endregion
    }
}
